﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TShock_AI
{
    public class Config
    {
        public bool Enable = true;
        public float DamageMultipler = 1f;
        public float SpeedMultipler = 1f;
        public static string path = "./tshock/ai.json";
        public static Config LoadConfig()
        {
            if (!File.Exists(path))
            {
                Config config = new Config();
                File.WriteAllText(path, JsonConvert.SerializeObject(config));
                return config;
            }
            else
            {
                Config config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(path));
                if (config == null)
                {
                    throw new FormatException("配置文件'ai.json'读取出错！");
                }
                return config;
            }
        }
    }
}
